fix(albums): index freshly-added album when dir has a stale photomap_index#247
Merged
Conversation
…tomap_index If the directory chosen for a new album already contained a ``photomap_index/embeddings.npz`` from a prior session (e.g. the user recreated an album over the same folder), creating the album appeared to succeed but the indexing UI got stuck at "Index updated …" in orange with 0% completion that never advanced. The new album silently inherited the old index. Two compounding bugs: * ``startAutoIndexing`` — the only entry point that runs after ``addAlbum`` — called ``showProgressUI`` and nothing else. It assumed indexing was already running, which was only true when ``getIndexMetadata`` failed and fired the ``albumIndexError`` event. With a stale ``embeddings.npz`` in place, the metadata fetch succeeds, no error event fires, and indexing was never started. Now ``startAutoIndexing`` scrolls into view and calls ``startIndexing`` directly. ``startIndexing`` is already idempotent — its backend progress probe attaches to any in-flight run instead of double-POSTing ``/update_index_async/``. * ``updateAlbumCardIndexStatus`` set ``status.style.color = "green"`` inline but didn't reset ``className``. CSS for ``.index-status.indexing`` carries ``!important`` (so the in-progress state's color wins over inline updates from ``updateProgressStatus``), which meant a stale ``.indexing`` class left behind by ``showProgressUI`` overrode the inline green. Resetting className to the bare ``index-status`` fixes the color and makes future state classes win cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
After creating a new album whose chosen image directory already contained a stale `photomap_index/embeddings.npz` from a prior session (e.g. recreating an album over the same folder), creating the album appeared to succeed but the indexing UI got stuck at "Index updated …" in orange at 0% completion that never advanced. The new album silently inherited the old index — searches and the UMAP were against the prior session's image set, not the current one.
Root cause
Two compounding bugs:
`startAutoIndexing` never actually started indexing. It's the only entry point that runs after `addAlbum`, and it just called `showProgressUI` on a 500 ms timer with a comment "Don't start indexing again - it's already running." The only path that does start indexing for a new album was the `albumIndexError` event fired from `getIndexMetadata` when the index returns 404. With a stale `embeddings.npz` already on disk, the metadata fetch succeeds, no error event fires, and `/update_index_async/` is never POSTed.
CSS `!important` orange wins over inline green. `updateAlbumCardIndexStatus` set `status.style.color = "green"` inline but never reset `className`. The CSS for `.index-status.indexing` carries `color: #ff9800 !important` (so the in-progress state wins over the inline updates that `updateProgressStatus` makes per status transition). When `showProgressUI` runs first and sets `className = "index-status indexing"`, the inline green that `updateAlbumCardIndexStatus` sets afterwards has no visual effect.
Fix
Test plan
🤖 Generated with Claude Code